<%@page import="entity.PageInfo"%>
<%@page import="entity.Teacher"%>
<%@page import="java.util.ArrayList"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" type="text/css" href="static/bootstrap-3.3.7-dist/css/bootstrap.css"/>
</head>
<body>
	<a href="${pageContext.request.contextPath}/teacher_insert.jsp">添加</a>
	<table  class="table table-striped table-bordered table-hover table-condensed">
		<tr>
			<th>ID</th>
			<th>名字</th>
			<th>年龄</th>
			<th>薪资</th>
			<th>删除</th>
			<th>修改</th>
		</tr>
		<c:forEach items="${pageInfo.list}" var="teacher"> 
			<tr>
				<td>${teacher.id}</td>
				<td>${teacher.name}</td>
				<td>${teacher.age}</td>
				<td>${teacher.salary}</td>
				<td><a href="${pageContext.request.contextPath}/teacher?method=deleteById&id=${teacher.id}">删除</a></td>
				<td><a href="${pageContext.request.contextPath}/teacher?method=selectById&id=${teacher.id}">修改</a></td>
			</tr>
		</c:forEach>
	</table>
	
	<nav aria-label="Page navigation">
		  <ul class="pagination">
		  	<c:if test="${pageInfo.pageNo==1}">
		  		<li  class="disabled">
				    <a href="#" aria-label="Previous">
				       <span aria-hidden="true">&laquo;</span>
				     </a>
				 </li>
		  	</c:if>
		  	<c:if test="${pageInfo.pageNo!=1}">
		  		<li>
			       <a href="${pageContext.request.contextPath}/teacher?method=selectByPage&pageNo=${pageInfo.pageNo-1}" aria-label="Previous">
			         <span aria-hidden="true">&laquo;</span>
			       </a>
				 </li>
		  	</c:if>
		  	
		  	<c:forEach begin="1" end="${pageInfo.totalPage}" var="i">
		  		<c:choose>
		  			<c:when test="${pageInfo.pageNo==i}">
		  				<li class="disabled"><a href="#">${i}</a></li>
		  			</c:when>
		  			<c:otherwise>
		  				<li><a href="${pageContext.request.contextPath}/teacher?method=selectByPage&pageNo=${i}">${i}</a></li>
		  			</c:otherwise>
		  		</c:choose>
		  	</c:forEach>
		   
		    <li>
		      <a href="${pageContext.request.contextPath}/teacher?method=selectByPage&pageNo=${pageInfo.pageNo+1}" aria-label="Next">
		        <span aria-hidden="true">&raquo;</span>
		      </a>
		    </li>
		  </ul>
		</nav>
</body>
</html>